var offsetMain = 100;

var path_css = "../css";
var path_ajax = "../ajax_php";

var color_letters_active = "#4e3427";
var color_letters = "#ccc";

var border_on = "solid 1px #e0d8d5";
var color_cell_on = "#26160f";
var size_cell_on = "12pt";

var border_out = "solid 1px #fff";
var color_cell_on = "#4e3427";
var size_cell = "10pt";

$(document).ready(function() {

    var menu = $("div#menu");
    var header_line = $("div#header");
    var main = $("div.main");
    var offset = $("#offset");
    var footer = $("div#footer");
    var desc = $("div#desc");
    var tellFriends = $("div#tellFriends");
    var links_foot = $("div#links_foot");
    var container = $("div#container");
    var rules = $("#rules").html();
    var IsIE = $(".isIE").html();
    
    changeMainStyle_onResizing();
    setHeight(header_line, offset, main, footer, offsetMain,container);

    /*HANDLING OF RESIZING EVENT*/
    $(window).resize(function (){
        changeMainStyle_onResizing();
        setHeight(header_line, offset, main, footer, offsetMain,container);
    });
    
    /*EVENT WHEN MOUSE IS ABOVE THE BUTTON*/
    $("input[type='image']").mouseenter(function(){
        var id = this.id;
        $(this).attr('src', path_css + '/image/' + switch_button(id) + '_on.png');
    });
  
    /*EVENT WHEN MOUSE LEFT AREA OF THE BUTTON*/
    $("input[type='image']").mouseleave(function(){
       var id = this.id;
       $(this).attr('src', path_css + '/image/' + switch_button(id) + '.png');
    });
    
    /*EVENT WHEN MOUSE PRESSED THE BUTTON*/
    $("input[type='image']").mouseup(function(){
        var id = this.id;
        $(this).attr('src', path_css + '/image/' + switch_button(id) + '.png');
    }).mousedown(function(){
        var id = this.id;
        $(this).attr('src', path_css + '/image/' + switch_button(id) + '_press.png');
    });
    
    function changeMainStyle_onResizing(){
         /*if(rules != null){
            //main.css("width", "40em");
           if(IsIE != null){
                
            }
        }*/
    }
});
/*--------------------------------------------------------------------------------------------------------------*/
/*FUNCTION TO SET HEIGHT OF CONTAINER, WHICH IS BETWEEN HEADER AND FOOTER*/
function setHeight(menu, offset, main,  footer, offsetMain,container){
    
    var borderHeader = 0;
    var marginHeader = parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom'));
    
    var marginMain = parseInt(main.css('margin-top')) + parseInt(main.css('margin-bottom'));
    
    var borderFooter = parseInt(footer.css('border-top-width'));
    var marginFooter = parseInt(footer.css('margin-top')) + parseInt(footer.css('margin-bottom'));
    
    
    var headerHeight = marginHeader + menu.height() + borderHeader;
    var mainHeight = marginMain + main.height();
    var footerHeight = marginFooter + footer.height() + borderFooter;
    
    var curr_height = headerHeight + mainHeight + footerHeight +offset.height();
    
    if(curr_height > $(window).height()){
        footer.css('position',"relative");
        curr_height = headerHeight + mainHeight + footerHeight + offset.height();
        container.css("height", curr_height);
    }
    else{
        footer.css({'position':'absolute','bottom':'0'});
        container.css("height","100%");
    }
}

function switch_button(id){
    var result = "";
    switch (id) {
        case 'btn_show':
            result = 'show';
            break;
        case 'btn_print':
            result = 'print';
            break;
        case 'btn_moder':
            result = 'send';
            break;
        case 'btn_send':
            result = 'send';
            break;
        case 'btn_login':
            result = 'login';
            break;
        case 'btn_logout':
            result = 'logout';
            break;
        default:
            break;
    }
    return result;
}
    